<template>
    <view class="content">
        <u--form ref="uForm" :model="thisData" :rules="rules" label-width="100" labelAlign="center">
            <u-form-item label="初始小破断力" borderBottom>
                <u-input type="number" :formatter="$gx.inputFormatter" v-model="thisData.originKn" placeholder="" :disabled="isSee"> </u-input>
            </u-form-item>
            <u-form-item label="实测最小破断力" borderBottom>
                <u-input type="number" :formatter="$gx.inputFormatter" v-model="thisData.minKn" placeholder="" :disabled="isSee"> </u-input>
            </u-form-item>
            <u-form-item label="最小破断损失百分比" borderBottom>
                <u-input type="number" :formatter="$gx.inputFormatter" v-model="thisData.minKnPercent" placeholder="" :disabled="isSee"> </u-input>
            </u-form-item>
            <u-form-item label="拆股试验报告" borderBottom>
                <view class="w-100">
                    <Upload ref="fiel1Ref" v-model="thisData.attr1_FilesList" :disabled="isSee" :limit="9" @onPreviewShow="onPreviewShow" @onPreviewHide="onPreviewHide"></Upload>
                </view>
            </u-form-item>
            <u-form-item label="破断试验报告" borderBottom>
                <view class="w-100">
                    <Upload ref="file2Ref" v-model="thisData.attr2_FilesList" :disabled="isSee" :limit="9" @onPreviewShow="onPreviewShow" @onPreviewHide="onPreviewHide"></Upload>
                </view>
            </u-form-item>
            <u-form-item label="评估报告" borderBottom>
                <view class="w-100">
                    <Upload ref="file3Ref" v-model="thisData.attr3_FilesList" :disabled="isSee" :limit="9" @onPreviewShow="onPreviewShow" @onPreviewHide="onPreviewHide"></Upload>
                </view>
            </u-form-item>

            <u-form-item label="专家评估建议" borderBottom>
                <view class="w-100">
                    <Upload ref="file4Ref" v-model="thisData.attr4_FilesList" :disabled="isSee" :limit="9" @onPreviewShow="onPreviewShow" @onPreviewHide="onPreviewHide"></Upload>
                </view>
            </u-form-item>
        </u--form>
        <view class="mart-30" v-if="!isSee">
            <u-row justify="center">
                <u-col span="6">
                    <u-button type="primary" @click="onSubmit">提交</u-button>
                </u-col>
            </u-row>
        </view>
        <u-toast ref="uToast"></u-toast>
    </view>
</template>

<script>
export default {
    data() {
        return {
            thisData: {
                attr1_FilesList: [],
                attr2_FilesList: [],
                attr3_FilesList: [],
                attr4_FilesList: [],
            },
            rules: {},
            isSee: false,
        };
    },
    onLoad(option) {
        if (option.isSee) {
            this.isSee = true;
        }
        this.init(option.id);
    },
    methods: {
        init(id) {
            this.$app.CallApi(this.$app.api.UsingWirerope.GetByID(id), {
                success: (res) => {
                    this.thisData = res;
                },
            });
        },
        //保存
        onSubmit() {
            this.$app.CallApi(this.$app.api.UsingWirerope.UpdateZuoFeiInfo, {
                data: this.thisData,
                success: (res) => {
                    this.$refs.uToast.show({
                        type: "success",
                        title: "",
                        message: "提交成功！",
                        complete: () => {
                            uni.navigateBack();
                            uni.$emit("refreshData");
                        },
                    });
                },
            });
        },
        //文件预览开启
        onPreviewShow() {
            this.$refs.fiel1Ref.setReadOnly(true);
            this.$refs.file2Ref.setReadOnly(true);
            this.$refs.file3Ref.setReadOnly(true);
            this.$refs.file4Ref.setReadOnly(true);
        },
        //文件预览关闭
        onPreviewHide() {
            this.$refs.fiel1Ref.setReadOnly(false);
            this.$refs.file2Ref.setReadOnly(false);
            this.$refs.file3Ref.setReadOnly(false);
            this.$refs.file4Ref.setReadOnly(false);
        },
    },
};
</script>

<style></style>
